﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for FleetCarDriverDB
/// </summary>
namespace CE.CarInsurance
{
    public class FleetCarDriverDB
    {
        public Int64 Insert(FleetCarDriver fleetcardriver)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocFleetCarDriverInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@FleetCarDriverId", fleetcardriver.FleetCarDriverId);
            _sPara.Add("@FleetCarId", fleetcardriver.FleetCarId);
            _sPara.Add("@CompanyId", fleetcardriver.CompanyId);
            _sPara.Add("@RefCEUserId", fleetcardriver.RefCEUserId);
            _sPara.Add("@AgentId", fleetcardriver.AgentId);
            _sPara.Add("@FullName", fleetcardriver.FullName);
            _sPara.Add("@DOB", fleetcardriver.DOB);
            _sPara.Add("@IDNo", fleetcardriver.IDNo);
            _sPara.Add("@LicenseNumber", fleetcardriver.DrivingLicenseNumber);
            _sPara.Add("@Status", fleetcardriver.Status);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public Int64 Delete(Int64 FleetCarDriverId, Int64 FleetCarId, Int64 CompanyId, Int64 RefCEUserId)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocFleetCarDriverDeleteSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@FleetCarDriverId", FleetCarDriverId);
            _sPara.Add("@FleetCarId", FleetCarId);
            _sPara.Add("@CompanyId", CompanyId);
            _sPara.Add("@RefCEUserId", RefCEUserId);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataTable GetCarDriverList(Int64 FleetCarId, Int64 CompanyId)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "sprocFleetCarDriverDetailSelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@FleetCarId", FleetCarId);
            _spara.Add("@CompanyId", CompanyId);

            DataTable _dt = _db.GetDataTableBySP(_spName, _spara);
            return _dt;
        }

    }
}